home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / ISIZE.ASM < prev    next >
Assembly Source File  |  1991-10-12  |  1KB  |  64 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7. ;
  8. ; ISize- Returns the number of print positions required by an integer value.
  9. ;       On Input:
  10. ;                       AX: Integer to get the size of.
  11. ;
  12. ;       On Output:
  13. ;                       AX: Digit count for the integer.
  14. ;
  15.         public  sl_ISize
  16. sl_ISize    proc    far
  17.         cmp     ax, 0
  18.         jge     ISize2
  19.         neg     ax
  20.         call    GetUSize
  21.         inc     ax
  22.         ret
  23. ;
  24. ISize2:         call    GetUSize
  25.         ret
  26. sl_ISize    endp
  27. ;
  28. ; USize- Same as above, except for unsigned numbers.
  29. ;
  30.         public  sl_USize
  31. sl_USize        proc    far
  32.         call    GetUSize
  33.         ret
  34. sl_USize        endp
  35. ;
  36. ; GetUSize- Does the actual size comparison.
  37. ;
  38. GetUSize        proc    near
  39.         cmp     ax, 10
  40.         jae     GUS1
  41.         mov     ax, 1
  42.         ret
  43. ;
  44. GUS1:           cmp     ax, 100
  45.         jae     GUS2
  46.         mov     ax, 2
  47.         ret
  48. ;
  49. GUS2:           cmp     ax, 1000
  50.         jae     GUS3
  51.         mov     ax, 3
  52.         ret
  53. GUS3:           cmp     ax, 10000
  54.         jae     GUS4
  55.         mov     ax, 4
  56.         ret
  57. ;
  58. GUS4:           mov     ax, 5
  59.         ret
  60. GetUSize        endp
  61. ;
  62. stdlib        ends
  63.         end
  64.